/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author nino
 */

import java.sql.*;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class dbutil {
                        
        private static String url="jdbc:mysql://localhost:3306/Snake";
	private static String username = "root";
	private static String password = "12345678";
	private static String tablename= "snakedb";  
        private static Connection conn ;
        private static Statement st; 
   
         //create a database connection
         public static Connection getconnection(){
		try {
		Class.forName("com.mysql.jdbc.Driver"); 
			System.out.println("Class Found");

		} catch(java.lang.ClassNotFoundException e) {
			System.err.print("ClassNotFoundException: ");
			System.err.println(e.getMessage());
		}

		try {
			conn = DriverManager.getConnection(url,username, password);
			System.out.println("Connection established");

		} catch(SQLException ex) {
			System.err.println("SQLException: " + ex.getMessage());
		}
                return conn;
         }
 /*        
	public void createTable()
	{
		Connection conn =  getconnection();		
		String createString;
		createString = "create table snaketable (" +
							"ID " +
							"Score"
                        +"Level";
		try {
			stmt = conn.createStatement();
	   		stmt.executeUpdate(createString);
			stmt.close();
			conn.close();
		} catch(SQLException ex) {
			System.err.println("SQLException: " + ex.getMessage());
		}
		JOptionPane.showMessageDialog(null,"Snake Table Created");
	}         
;
 */  
         //add a new function to check if the gameid already exist
}
